/*
 * Problem: K-th(POJ 3468)
 * Created: 2022/03/02
 * Author: Yuanshun L
 * Algorithm: Bucket Method
 */

#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define qc ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)

const int B = 1000; // the number of bucket
const int MAX_N = 1e5 + 5;
const int MAX_M = 5e3 + 5;

// input
int N,M;
int data[MAX_N]; // raw data
int nums[MAX_N]; // data is sorted
int L[MAX_M],R[MAX_M],K[MAX_M]; // query

vector<int> buckets[MAX_N/B];


void solve(){

    for(int i=0;i<N;i++){
        buckets[i/B].push_back(data[i]);
        nums[i] = data[i];
    }
    sort(nums,nums+N);

    // If not fully filled, the last bucket will not be sorted,
    // but there are no problem
    for(int i=0;i<N/B;i++){
        sort(buckets[i].begin(),buckets[i].end());
    }

    // the k-th number in [L,r)
    for(int i=0;i<M;i++){
        int l = L[i]-1,r = R[i],k = K[i];

        int lb = -1,ub = N-1;
        while(ub - lb > 1){
            int cnt = 0;
            int mid = (ub+lb) / 2;
            int x = nums[mid];
            int tl = l,tr = r;

            while(tl < tr && tl % B != 0)
                if(data[tl++] <= x) cnt++;
            while(tl < tr && tr % B != 0)
                if(data[--tr] <= x) cnt++;

            while(tl<tr){
                int b = tl / B;
                cnt += upper_bound(buckets[b].begin(),buckets[b].end(),x) - buckets[b].begin();
                tl += B;
            }

            if(cnt >= k) ub = mid;
            else lb = mid;
        }
        printf("%d\n",nums[ub]);
    }
}

int main(){
    qc;
//    freopen("data.in","r",stdin);
//    freopen("data.out","w",stdout);

    cin >> N >> M;
    for(int i = 0;i < N;i++)
        scanf("%d",&data[i]);
    for(int i = 0;i < M;i++){
        scanf("%d%d%d",&L[i],&R[i],&K[i]);
    }
    solve();
    return 0;
}
